@extends('admin.layout.master')
@section('content')
    <!-- TAB NAVIGATION -->
    <ul class="nav nav-tabs" role="tablist">
        <li><a href="/admin/slider/">轮播图列表</a></li>
        <li class="active"><a href="#">新增轮播图</a></li>
    </ul>

    <form action="/admin/slider" method="post" class="form-horizontal" role="form">
        @csrf
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">轮播图管理</h3>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">标题</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="title" required="required"  value={{old('title')}}>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">作者</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="name" required="required" value={{old('name')}}>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">跳转地址</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="url" required="required" value={{old('url')}}>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">预览图</label>
                    <div class="col-sm-10">
                        <div class="input-group">
                            <input type="text" class="form-control" name="image" readonly="required"
                                   value="images/nopic.jpg" required>
                            <div class="input-group-btn">
                                <button onclick="upImage(this)" class="btn btn-default"
                                        type="button">选择图片
                                </button>
                            </div>
                        </div>
                        <div class="input-group" style="margin-top:5px;">
                            <img src="{{asset('images/nopic.jpg')}}"
                                 class="img-responsive img-thumbnail" width="150">
                            <em class="close" style="position:absolute; top: 0px; right: -14px;"
                                title="删除这张图片" onclick="removeImg(this)">×</em>
                        </div>
                    </div>
                    <script>
                        //上传图片
                        function upImage(obj) {
                            require(['util'], function (util) {
                                options = {
                                    multiple: false,//是否允许多图上传
                                };
                                util.image(function (images) {          //上传成功的图片，数组类型
                                    $("[name='image']").val(images[0]);
                                    $(".img-thumbnail").attr('src', images[0]);
                                }, options)
                            });
                        }

                        //移除图片
                        function removeImg(obj) {
                            $(obj).prev('img').attr('src', 'resource/images/nopic.jpg');
                            $(obj).parent().prev().find('input').val('');
                        }
                    </script>
                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">是否显示</label>
                        <div class="col-sm-10">
                            <label class="radio-inline">
                                <input type="radio" name="is_show" value="1">
                                是
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="is_show" value="0" checked="checked">
                                否
                            </label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">查看次数</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="click" required="required" value="500">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <button class="btn btn-success">保存内容</button>
    </form>

@endsection
